﻿@section Header{
    <style>
        .hu-wid50{
            width:50%;
        }
        .verificationImg {
            width: 5rem;
            height: 4.2rem;
            /* height: 100%; */
            /* float: left; */
            /* padding-left: 5.2rem; */
            margin-left: 5rem;
        }
    </style>
}
<div class="login-bg">
    <div class="login">
        <div class="message">蛮牛美食管理登录</div>
        <div id="darkbannerwrap"></div>
        <form method="post" id="fomrs"  class="layui-form">
            <input name="username" placeholder="用户名" type="text" lay-verify="myrequired" class="layui-input">
            <hr class="hr15">
            <input name="password" lay-verify="required" placeholder="密码" type="password" class="layui-input">
            <hr class="hr15">
                <input name="verificationcode" lay-verify="required" placeholder="验证码" type="text" class="layui-input l" style="width:50%;display:inline-block">
                <img  src="/admin/Login/GetIamgCode" class=" verificationImg" />
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" id="btnsve" type="button">
            <hr class="hr20">
        </form>
    </div>
</div>
@section footer{
<script>
    $(function () {
        layui.use('form', function () {
            var form = layui.form;
            var layer = layui.layer;
            /*form.verify({
                myrequired: function (value,item) {

                    if (value=="")
                    {
                        return "用户名不能为空";
                    }
                 }
            })*/ 

            $("#btnsve").click(function () {

                if ($("input[name='username']").val()=="")
                {
                    layer.msg("用户名不能为空", {icon:4});
                    return ;
                }
                if ($("input[name='username']").val().length>20) {
                    layer.msg("用户名最大长度20", { icon: 4 });
                    return;
                }
                if ($("input[name='password']").val() == "") {
                    layer.msg("密码不能为空", { icon: 4 });
                    return;
                }
                if ($("input[name='password']").val().length > 20) {
                    layer.msg("密码最大长度20", { icon: 4 });
                    return;
                }
                if ($("input[name='verificationcode']").val() == "") {
                    layer.msg("验证码不能为空", { icon: 4 });
                    return;
                }
                $.post("/admin/Login/Login", $("#fomrs").serializeArray(), function (data) {

                    if (!data.succeed) {

                        layer.msg(data.msg);
                        $(".verificationImg").attr("src", "/admin/Login/GetIamgCode?dis=" + (Math.random()*120))
                    }
                    else
                    {
                        window.location.href = '/admin/admin/index';
                    }
                });
            })
      
        
        })
    })


</script>

}
